package Java_Concurrency_in_Practice.c5_3_1;

import java.io.File;
import java.io.FileFilter;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class StartIndexing {

	public static void startIndexing(File[] roots) {
		BlockingQueue<File> queue = new LinkedBlockingQueue<File>();
		
		FileFilter filter = new FileFilter() {
			@Override
			public boolean accept(File pathname) {
				return true;
			}
		};
		
		for (File root : roots) {
			new Thread(new FileCrawler(queue, filter, root)).start();
		}
		
		int N_CONSUMERS = 11;
		for (int i = 0; i < N_CONSUMERS; i++) {
			new Thread(new Indexer(queue)).start();
		}
		
		
	}
}
